package com.example._003configtest;

import com.example._003configtest.mybean.MyBean;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportResource;

////额外指定扫描com.example._003configtest.config包下所有的配置类和Beans组件
//@SpringBootApplication(scanBasePackages = {"com.example._003configtest.config","com.example._003configtest.mybean","com.example._003configtest.controller"})
////加载类加载路径下beans.xml文件作为配置文件
@ImportResource("classpath:beans.xml")
////加载com.example._003configtest.config包下的MyConfig文件作为配置类
//@Import(com.example._003configtest.config.MyConfig.class)
@SpringBootApplication
public class Application {

    public static void main(String[] args) throws InterruptedException {
        SpringApplication app = new SpringApplication(Application.class);
        //设置web应用的类型，如果不设置则使用默认的类型，如果有Spring Web依赖，则自动是基于Servlet的Web应用
        //如果有Spring WebFlux依赖，则自动是反应式Web应用
        app.setWebApplicationType(WebApplicationType.REACTIVE);
        //创建Spring容器，运行Spring Boot应用
        ConfigurableApplicationContext run = app.run(args);
        System.out.println(run.getBean("myBean"));
    }

}
